# Huawei Technologies Co.,Ltd.

set(SIEVE_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sieve.txt)
set(SIEVE_BIN ${CMAKE_CURRENT_BINARY_DIR}/sieve.abc)
set(SIEVE_JS ${CMAKE_CURRENT_SOURCE_DIR}/sieve.js)
set(SIEVE_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${SIEVE_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${SIEVE_OUTPUT}
    COMMENT "running javascript sieve testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${SIEVE_JS} --output ${SIEVE_BIN}
    COMMAND rm -f ${SIEVE_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${SIEVE_OUTPUT}
    COMMAND bash ${SIEVE_VERIFY} ${SIEVE_OUTPUT}
)
add_custom_target(sieve
    DEPENDS ${SIEVE_OUTPUT} ${SIEVE_VERIFY}
)
add_dependencies(sieve es2panda ark)
add_dependencies(ecmascript_common_tests sieve)
